﻿select ID,_UpdateStamp from DBDictionary.DBInstrumentStaticData where _UpdateStamp> 1000
exec spGetUpdatedRowsSince N'DBDictionary.DBMarket',20090820230707;
exec spGetUpdatedRowsSince N'DBDictionary.DBTickSizeRule',20090820230707;
exec spGetUpdatedRowsSince N'DBDictionary.DBInstrumentStaticData',20090820230707;

--select * from DBDictionary.DBMarket;
--select * from DBDictionary.DBTickSizeRule;
--select * from DBDictionary.DBInstrumentStaticData;

------ Scratch'

----select * from DBDictionary.DBSector;
----select * from DBDictionary.DBCurrency;

----select * from DBDictionary.DBInstrumentEquity;
----select * from DBDictionary.DBInstrumentEquityVanillaOption;
----select * from DBDictionary.DBTickSizeRule;
----select * from DBDictionary.DBTickSizeRuleField;
----delete from DBDictionary.DBTickSizeRule;
----delete from DBDictionary.DBTickSizeRuleField;

---- select * from DBLiveObjects.DBConfigurationField;

---- select count(*) from DBLiveObjects.DBConfiguration;

----update DBDictionary.DBInstrument set DBFeedPluginID=null, DBFeedPluginInstrumentConfigurationID=null;

----SELECT * from DBLiveObjects.DBConfiguration;
----select * from DBLiveObjects.DBConfigurationField order by DBConfigurationID;

----select * from DBDictionary.DBDictionary;
---- select * from DBDictionary.DBMarket;
----select * from DBDictionary.DBInstrumentEquity;
----select * from DBDictionary.DBInstrumentForex;
----select * from DBDictionary.DBInstrumentForexFuture;
----select * from DBDictionary.DBInstrument;
----select * from DBLiveObjects.DBContainer;
----select * from DBBackOffice.DBBackOffice;

----delete from DBBackOffice.DBOrder;
----delete from DBBackOffice.DBOrderExecution;
----delete from DBBackOffice.DBOrderStatus;


----CREATE PROCEDURE [DBBackOffice.spPosition]
	----@start_date DateTime,
	----@end_date DateTime,
	----@booking_path Varchar(255)
----AS
	----SET DATEFORMAT YMD

	----declare @longleg float;
	----select @longleg = sum(+ Quantity * Price) from DBBackOffice.DBOrderExecution 
		----where Way = 'Buy' 
			----and TimeStamp>=@start_date 
			----and TimeStamp<=@end_date
			----and Path Like @booking_path;
	----declare @shortleg float;
	----select @shortleg = sum(+ Quantity * Price) from DBBackOffice.DBOrderExecution 
			----where Way = 'Sell' 
			----and TimeStamp>=@start_date 
			----and TimeStamp<=@end_date
			----and Path Like @booking_path;
			
	----declare @position float;
	----select @position = @longleg - @shortleg;
	----select @position;
----RETURN @position

----SELECT 'DBInstrumentStaticData',ID from DBDictionary.DBInstrumentStaticData
----SELECT 'DBCurrencyPrice',ID from DBDictionary.DBCurrencyPrice
----select * from DBDictionary.DBCurrencyPrice;


---- WAITFOR (RECEIVE * FROM NotificationMessagesQueue);   